<template>
  <div class="login-register">
    <div class="contain">
      <div class="big-box" :class="{active:isLogin}">
        <div class="big-contain" v-if="isLogin">
          <div class="title">账户登录</div>
          <div class="form">
            <el-input placeholder="请输入手机号"  clearable v-model="form.phone"></el-input>
            <el-input placeholder="请输入密码"  show-password v-model="form.passWord"></el-input>
          </div>
          <el-button type="primary"  @click="login">登录</el-button>
        </div>
        <div class="big-contain" v-else>
          <div class="title">创建账户</div>
          <div class="form">
            <el-input placeholder="请输入手机号"  clearable v-model="form.phone"></el-input>
            <el-input placeholder="请输入邮箱"  clearable v-model="form.email"></el-input>
            <el-input placeholder="请输入密码"  clearable v-model="form.passWord" show-password></el-input>
          </div>
          <el-button type="primary"   @click="register">注册</el-button>
        </div>
      </div>
      <div class="small-box" :class="{active:isLogin}">
        <div class="small-contain" v-if="isLogin">
          <div class="title_c">你好，朋友!</div>
          <p class="content">开始注册，和我们一起旅行</p>
          <el-button class="button—b"  @click="changeType">注册</el-button>
        </div>
        <div class="small-contain" v-else>
          <div class="title_c">欢迎回来!</div>
          <p class="content">与我们保持联系，请登录你的账户</p>
          <el-button class="button—b" @click="changeType">登录</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {setToken} from "@/utils/auth";

export default{
  name:'login-register',
  data(){
    return {
      isLogin:true,
      emailError: false,
      passwordError: false,
      existed: false,
      form:{
        passWord:'',
        phone:'',
        email:''
      }
    }
  },
  methods:{
    changeType() {
      this.isLogin = !this.isLogin
      this.form.username = ''
      this.form.userName = ''
      this.form.passWord = ''
    },
    login() {
      setToken("1233331")
      this.$router.push({path: '/dashboard'})
    },
    register(){
      const self = this;
      if(self.form.phone !== "" && self.form.email !== "" && self.form.passWord !== ""){

      } else {
        this.$message.error("填写不能为空");
      }
    }
  }
}
</script>

<style lang="less" scoped>
.login-register{
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
}
.contain{
  width: 60%;
  height: 60%;
  position: relative;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background-color: #fff;
  border-radius: 20px;
  box-shadow: 0 0 3px #f0f0f0,
  0 0 6px #f0f0f0;
}
.big-box{
  width: 70%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 30%;
  transform: translateX(0%);
  transition: all 1s;
}
.big-contain{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.title{
  font-size: 1.5em;
  font-weight: bold;
  color: rgb(57,167,176);
}
.form{
  width: 100%;
  height: 40%;
  padding: 2em 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}
.form .errTips{
  display: block;
  width: 50%;
  text-align: left;
  color: red;
  font-size: 0.7em;
  margin-left: 1em;
}
.form input{
  width: 50%;
  height: 30px;
  border: none;
  outline: none;
  border-radius: 10px;
  padding-left: 2em;
  background-color: #f0f0f0;
}
.button{
  width: 20%;
  height: 40px;
  border-radius: 24px;
  border: none;
  outline: none;
  background-color: rgb(57,167,176);
  color: #fff;
  font-size: 0.9em;
  cursor: pointer;
}
.small-box{
  width: 30%;
  height: 100%;
  //background: linear-gradient(135deg,rgb(57,167,176),rgb(56,183,145));
  background-image: linear-gradient(120deg, #89f7fe 0%, #66a6ff 100%);
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(0%);
  transition: all 1s;
  border-top-left-radius: inherit;
  border-bottom-left-radius: inherit;
}
.small-contain{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.title_c{
  font-size: 1.5em;
  font-weight: bold;
  color: #fff;
}
.content{
  font-size: 0.8em;
  color: #fff;
  text-align: center;
  padding: 2em 4em;
  line-height: 1.7em;
}
.button—b{
  width: 60%;
  height: 40px;
  border-radius: 24px;
  border: 1px solid #fff;
  outline: none;
  background-color: transparent;
  color: #fff;
  font-size: 0.9em;
  cursor: pointer;
}

.big-box.active{
  left: 0;
  transition: all 0.5s;
}
.small-box.active{
  left: 100%;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-top-right-radius: inherit;
  border-bottom-right-radius: inherit;
  transform: translateX(-100%);
  transition: all 1s;
}

.el-input{
  width: 50%;
}

</style>
